package com.itheima.service.impl;

import com.itheima.service.SendMailService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.mail.SimpleMailMessage;
import org.springframework.mail.javamail.JavaMailSender;

/**
 * ClassName: SendMailServiceImpl
 * Description:
 * Date: 2023/03/14 AM 12:43:42
 * <p>
 * project: springboot
 * package: com.itheima.service.impl
 * email: 1085844536@qq.com
 * version:
 *
 * @author WangGuojian
 */
// @Service
public class SendMailServiceImpl implements SendMailService {

    @Autowired
    private JavaMailSender javaMailSender;

    /**
     * 发送人
     */
    private String from = "1085844536@qq.com";

    /**
     * 收件人
     */
    private String to = "1085844536@qq.com";

    /**
     * 主题
     */
    private String subject = "测试邮件";

    /**
     * 正文
     */
    private String context = "测试邮件正文内容";

    /**
     * 发送邮件
     */
    @Override
    public void sendMail() {
        SimpleMailMessage message = new SimpleMailMessage();
        message.setFrom(from + "(小甜甜)");
        message.setTo(to);
        message.setSubject(subject);
        message.setText(context);
        javaMailSender.send(message);
    }
}
